# !/usr/bin/env python
# coding=utf-8
# @Time    : 2020/4/27 16:42
# @Author  : 6imensiva
# @Site    : https://gitee.com/dimensiva/SeleniumCrapy.git
# @File    : my_websocket.py
# @Software: PyCharm
# @Version: 2.7.5

import json
import time
from websocket import create_connection

ws = create_connection("ws://192.168.0.169:65100/websocket/1")
print("Sending 'Hello, World'...")
t=str(time.time()).split(".")[0]
params={
    "messageType": 1,
    "messageIdList": [4,5,6]
}

result = ws.recv()
print(result)


ws.send(json.dumps(params))
# print("Sent")
# print("Reeiving...")
# result = ws.recv()
# print("Received '{}'".format(result))
#
#
# params={
#     "version": 1,
#     "msgNo": t,
#     "machNo": "U040119110001",
#     "cmd": 7,
#     "time": t,
#     "data": {
#         "userId": 8,
#         "companyType": 3,
#         "before": 0,
#         "after": 100,
#         "openTime": t,
#         "closeTime": t
#     }
# }
#
# ws.send(json.dumps(params))
# print("Sent")
# print("Reeiving...")
# result = ws.recv()
# print("Received '{}'".format(result))
#
#
# ws.close()